/**
 * This class should have been implemented as action listener for the checkbox on buttons panel
 */
package slhs.tempo.scriptGenerator;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 * FeedbackOptionsPopup.java
 * 
 * @author Swapnil Devikar
 * 
 */
public class StartPulseOptionsPopup extends JFrame implements ActionListener {

    private static final StartPulseOptionsPopup startPulseOptionsPopup = new StartPulseOptionsPopup();
    private JPanel startPulseOptionsPanel;
    private StartPulseOptionsPanelHandler startPulseOptionsPanelHandler;

    private StartPulseOptionsPopup() {
	super("Start Pulse Options");
	this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
	this.setSize(420, 150);
	startPulseOptionsPanelHandler = new StartPulseOptionsPanelHandler();
	startPulseOptionsPanel = startPulseOptionsPanelHandler.getPanel();
	this.add(startPulseOptionsPanel);
    }

    /**
     * Method to show/hide the frame
     */
    private void draw(boolean show) {
	this.setVisible(show);
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
     */
    @Override
    public void actionPerformed(ActionEvent event) {
	JCheckBox source = (JCheckBox) event.getSource();
	if (source.isSelected()) {
	    draw(true);
	    source.setSelected(false);
	} else
	    draw(false);

    }

    /**
     * @return
     */
    public static StartPulseOptionsPopup getInstance() {
	return startPulseOptionsPopup;
    }

    /**
     * @return
     */
    public String getStartPulseOptions() {
	String startPulseOptions = startPulseOptionsPanelHandler.getStartPulseOptions();
	return startPulseOptions;
    }

}
